package cn.com.dingtek.genius.manager.server.support;


import lombok.Getter;
import lombok.ToString;

import java.util.Arrays;
import java.util.Optional;

@Getter
public enum DeviceType {
    /**
     *
     */
    TRASH_CAN(1, "智能垃圾箱"),
    CAR_PARK(2, "智能停车"),
    CAR_PARK_DUAL(3, "智能停车(双模)"),
    SEWER_COVER(4, "智能井盖"),
    SIGNPOST(5, "智能指路牌");

    private int value;
    private String desc;

    DeviceType(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static Optional<DeviceType> valueOf(Integer value) {
        return Arrays.stream(DeviceType.values())
                .filter(item -> item.getValue() == value)
                .findFirst();
    }

    @Override
    public String toString() {
        return desc;
    }
}
